<template>
  <div class="header-two">

    <div class="header-hm">
      <el-row type="flex" justify="space-between">
        <el-page-header content="添加企业" @back="fn" />
        <span style="float: right; padding: 3px 0" type="text">黑马管理员</span>
      </el-row>
    </div><br>
    <el-row type="flex" justify="center">
      <el-card class="box-card" style="width:1660px">
        <div slot="header" class="clearfix">
          <span>企业信息</span>
        </div>
        <div style="margin:20px 130px">
          <el-form
            ref="formRef"
            :model="formData"
            label-width="100px"
            title="企业信息"
          >
            <el-row type="flex" justify="space-around">
              <el-form-item label="企业名称：" prop="name">
                {{ formData.name }}
              </el-form-item>
              <el-form-item label="法人" prop="legalPerson">
                {{ formData.legalPerson }}
              </el-form-item>
            </el-row>
            <el-row type="flex" justify="space-around">
              <el-form-item label="注册地址：" prop="registeredAddress">
                {{ formData.registeredAddress }}
              </el-form-item>
              <el-form-item label="所在行业" prop="industryCode">
                {{ formData.industryCode }}
              </el-form-item>

              <el-form-item label="营业执照" prop="carBrand">
                <img :src="formData.businessLicenseUrl" alt="">
              </el-form-item>
            </el-row>
          </el-form></div>
      </el-card>
    </el-row>

    <el-row type="flex" justify="center" style="margin:20px 0 0 0">
      <el-card class="box-card" style="width:1660px">
        <div slot="header" class="clearfix">
          <span>联系人信息</span>
        </div>
        <div style="margin:20px 130px">
          <el-form>
            <el-row type="flex" justify="space-around">
              <el-form-item label="企业联系人：" prop="contact">
                {{ formData.contact }}
              </el-form-item>
              <el-form-item label="联系电话：" prop="contactNumber">
                {{ formData.contactNumber }}
              </el-form-item>
            </el-row>
          </el-form>

        </div>
      </el-card>
    </el-row>

    <el-row type="flex" justify="center" style="margin:20px 0 0 0">
      <el-card class="box-card" style="width:1660px">
        <div slot="header" class="clearfix">
          <span>联系人信息</span>
        </div>
        <div>
          <el-table :data="rentList">
            <el-table-column label="序号" type="index" :index="indexMethod" />
            <el-table-column label="租赁楼宇" prop="name" />
            <el-table-column label="合同状态" prop="status">
              <template #default="{row}">
                <el-tag v-if="row.status===0">待生效</el-tag>
                <el-tag v-else-if="row.status===1" type="success">生效中</el-tag>
                <el-tag v-else-if="row.status===2" type="info">已到期</el-tag>
                <el-tag v-else-if="row.status===3" type="warning">已退租</el-tag>
              </template>
            </el-table-column>
            <el-table-column label="租赁起止时间">
              <template #default="{row}">
                <span>{{ row.startTime +'至'+ row.endTime }}</span>
              </template>
            </el-table-column>
            <el-table-column label="租赁合同" prop="contractName">
              <template #default="{row}">
                <a style="color:skyblue">{{ row.contractName }} </a>
              </template>
            </el-table-column>
            <el-table-column label="录入时间" prop="createTime" />
            <el-table-column label="操作">
              <template #default="{row}">
                <a :href="row.contractUrl" style="color:skyblue">合同下载</a>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-card>
    </el-row>
  </div>
</template>

<script>
import { getDetailAPI } from '@/api/enterprise'

export default {
  data() {
    return {
      formData: {},
      rentList: []
    }
  },
  watch: {
    onReset(newValue) {
      // resetFields
      if (!newValue) {
        this.$refs.formRef.resetFields()
      }
    }
  },
  async created() {
    this.lookDetail()
  },
  methods: {
    fn() {
      window.history.go(-1)
    },
    async onGetDetail() {
      const res = await getDetailAPI(this.$route.id)
      this.formData = res.data
      this.rentList = res.data.rent
    },
    // 序号
    indexMethod(index) {
      // console.log(index, '我是index')
      return index + 1
    }

  }
}
</script>
  <style scoped>

  </style>
